package com.xiaoyg.string;

public class addStrings {

    public static void main(String[] args) {


        String num1 = "11";
        String num2 = "123";

        int i = num1.length() - 1;
        int j = num2.length() - 1;

        int carry = 0;
        StringBuilder stringBuilder = new StringBuilder();
        while (i>= 0 || j >=0){
            int n1 = i >= 0?num1.charAt(i)-'0':0;
            int n2 = j >= 0?num2.charAt(j)-'0':0;
            int sum = n1+n2+carry;
            carry = sum / 10;
            stringBuilder.append(sum%10);
            i--;
            j--;
        }
        if (carry>1){
            stringBuilder.append(1);
        }
        System.out.println(stringBuilder.reverse().toString());
    }

}
